<?php
    $display_by = $display_by ?? true;
    $display_visibility = $display_visibility ?? true;
    $display_number_links = $display_number_links ?? true;
?>

<div class="card card--illustrated" style="background-image: url('<?= url_media('covers', $collection->image_filename, 'collection-card.png') ?>');">
    <a class="card__body card__body--large" href="<?= url('collection', ['id' => $collection->id]) ?>">
        <div class="card__title card__title-ellipsis">
            <?= protect($collection->name) ?>
        </div>

        <p class="card__text card__text--oneline">
            <?php
                $by = '';
                if ($display_by):
                    if ($collection->type === 'feed'):
                        $by = _f('Feed %s', protect($collection->feedWebsite()));
                    else:
                        $by = _f('By %s', protect($collection->owner()->username));
                    endif;

                    $by = "<span class=\"card__ellipsis\">{$by}</span>";
                endif;

                $number_links = '';
                if ($display_number_links):
                    if ($collection->number_links === 0):
                        $number_links = _('no links');
                    else:
                        $number_links = _nf('%s link', '%s links', $collection->number_links, format_number($collection->number_links));
                    endif;

                    $number_links = "<span class=\"card__text--extend\">{$number_links}</span>";
                endif;

                echo $by;
                if ($by && $number_links):
                    echo '&nbsp;·&nbsp;';
                endif;
                echo $number_links;
            ?>

            <?php if ($display_visibility): ?>
                <span class="sticker">
                    <?php if ($collection->is_public): ?>
                        <?= _('public') ?>
                    <?php else: ?>
                        <?= _('private') ?>
                    <?php endif; ?>
                </span>
            <?php endif; ?>
        </p>

        <p class="card__text" title="<?= _('Publication frequency') ?>">
            <?= icon('line-chart') ?>
            <?= format_publication_frequency($collection->publication_frequency_per_year) ?>
        </p>
    </a>
</div>
